<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:81:"E:\wamp\wamp\www\s72\xingjian\public/../application/admin\view\arctile\index.html";i:1524992541;}*/ ?>


<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="<?php echo url('admin/index/index'); ?>">首页</a>
        </li>
        <li>文章管理</li>
        <li class="active">文章列表</li>
    </ul><!-- .breadcrumb -->

    <div class="nav-search" id="nav-search">
        <form class="form-search">
            <span class="input-icon">
                <input type="text" placeholder="关键词" class="nav-search-input" value="" id="nav-search-input" autocomplete="off" />
                <i class="icon-search nav-search-icon"></i>
            </span>
            <span style="display: inline-block;height: 25px;cursor: pointer;" id="searchName">搜索</span>

        </form>
    </div><!-- #nav-search -->
</div>

<div class="page-content">

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->

            <div class="row">
                <div class="col-xs-12">
                    <div class="table-responsive">
                        <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>作者</th>
                                <th>标题</th>
                                <th>封面</th>
                                <th>点赞</th>
                                <th>浏览</th>
                                <th>发布时间</th>
                                <th>栏目</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>

                            <tbody id="tbody">
                            <?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$info): $mod = ($i % 2 );++$i;?>
                            <tr>
                                <td><?php echo $info['id']; ?></td>
                                <td><?php echo $info['author']; ?></td>
                                <td><?php echo $info['title']; ?></td>
                                <td><img src="/static/upload/arc/<?php echo $info['thumb']; ?>" width="80"></td>
                                <td><?php echo $info['praise_num']; ?></td>
                                <td><?php echo $info['browse_num']; ?></td>
                                <td><?php echo Date('Y/m/d H:m:s',$info['release_time']); ?></td>
                                <td><?php echo $info['cateid']; ?></td>
                                <td class="status" data-status="<?php echo $info['status']; ?>">
                                    <?php switch($info['status']): case "0": ?>已禁用<?php break; case "1": ?>已启用<?php break; endswitch; ?>
                                </td>
                                <td>
                                    <a  href="/arctile/<?php echo $info['id']; ?>" class="green"> <i class="icon-edit bigger-120"></i> </a>
                                    <a href="javascript:void(0);" class="del"><span class="red"><i class="icon-trash bigger-120"></i></span>
                                    </a>
                                </td>
                            </tr>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                            </tbody>
                        </table>
                    </div><!-- /.table-responsive -->
                </div><!-- /span -->
            </div><!-- /row -->

        </div>
    </div><!-- /.row -->
</div><!-- /.page-content -->

<div class="row" style="margin-top: -130px;">
    <div class="col-md-4 col-md-offset-4" id="page_div">
        <?php echo $data->render(); ?>
    </div>
</div>

<script>
    //删除操作
    function doDel(){
        $('.del').click(function(){
            if(confirm('你确定要删除吗？')){
                var id = $(this).parent().siblings().eq(0).html();
                $.ajax({
                    type : 'delete',
                    url : '/arctile/'+id,
                    datatype : 'json',
                    success : function(data){
                        if(data.status){
                            alert('删除成功');
                            $('#btn-close').click();
                            setTimeout(function(){
                                $('#showarctile').click();
                            },300);
                        }else{
                            alert(data.message);
                        }
                    },
                    error : function(){
                        alert('请求失败！');
                    }
                });
            }
        });
    }
    doDel();


    function search(){
        $('#searchName').click(function(){

            var title = $('#nav-search-input').val();

            $.ajax({
                type : 'post',
                url : "<?php echo url('admin/arctiles/ajaxListSearch'); ?>",
                data : {'title':title},
                datatype : 'json',
                success : function (data,status) {
                    locality(data,status);
                },
                error : function () {

                }
            });
        });
    }
    search();

    function AjaxPage(page) {
        $.ajax({
            url:"<?php echo url('/admin/arctiles/ajaxListAction'); ?>",
            type:"POST",
            data:{apage:page},
            success: function(data,status){
                console.log(data);
                locality(data,status);
            }
        });
    }

    function locality(data,status){
        var add_html = '';
        var list = data.data.data;
        var html_page = data.page;
        for (var i=0;i<list.length;i++){
            var status = '';
            if(list[i].status){
                status = '已启用';
            }else{
                status = '已禁用';
            }
            add_html += "<tr><td>"+list[i].id+"</td><td>"+list[i].author+"</td><td>" +list[i].title+"</td><td><img src=\"/static/upload/arc/"+list[i].thumb+"\" width=\"80\"></td><td>"+list[i].praise_num+"</td><td>"+list[i].browse_num+"</td><td>"+list[i].browse_num+"</td><td class='status' data-status="+list[i].status+">"+status+"</td><td>"+list[i].cateid+"</td><td><a  href=\"/arctile/"+list[i].id+"\" class=\"green\"> <i class=\"icon-edit bigger-120\"></i> </a>\n" + "<a href=\"javascript:void(0);\" class=\"del\"><span class=\"red\"><i class=\"icon-trash bigger-120\"></i></span>\n"+"</a></td></tr>";
        }


        $("#tbody").html(add_html);
        $("#page_div").html(html_page);
        //doDel();
    }
</script>


